package socket;

import java.net.Socket;

public class SocketChecker {
    public static boolean checkSocket(String host, int port) {
        boolean ok = false;
        Socket s = null;
        try {
            s = new Socket(host, port);
            s.setSoTimeout(100);
            ok = true;
        } catch (Exception e) {

            ok = false;
        } finally {
            if (s != null) {
                try {
                    s.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                s = null;
            }
        }
        return ok;
    }
}
